//
//  CommodityDetailViewController.m
//  CommodityManager
//
//  Created by lanou3g on 15/5/29.
//  Copyright (c) 2015年 libertyair. All rights reserved.
//

#import "CommodityDetailViewController.h"
#import "CommodityTableViewCell.h"
@interface CommodityDetailViewController ()

@end

@implementation CommodityDetailViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view from its nib.
    self.view.backgroundColor=[UIColor whiteColor];
    self.navigationItem.title=@"商品信息";
    UIBarButtonItem*rightBI=[[UIBarButtonItem alloc] initWithTitle:@"保存" style:UIBarButtonItemStylePlain target:self action:@selector(keepInfo)];
    self.navigationItem.rightBarButtonItem=rightBI;
    //设置代理
    _nameText.delegate=self;
    _numberText.delegate=self;
    _priceText.delegate=self;
    
    //传值
    CommodityTableViewCell*commodityCell=[[CommodityTableViewCell alloc] init];
    _nameText.text=commodityCell.nameLabel.text;
    
    _numberText.text=commodityCell.numberLabel.text;
    _priceText.text=commodityCell.priceLabel.text;
    
}

//保存按钮  修改商品的信息
-(void)keepInfo
{
    UIAlertView*alert1=[[UIAlertView alloc] initWithTitle:@"修改商品信息成功" message:nil delegate:self cancelButtonTitle:nil otherButtonTitles:@"确定", nil];
    UIAlertView*alert2=[[UIAlertView alloc] initWithTitle:@"修改商品信息失败" message:nil delegate:self cancelButtonTitle:nil otherButtonTitles:@"确定", nil];
    if ([_nameText.text isEqualToString:@""]||[_numberText.text isEqualToString:@""]||[_priceText.text isEqualToString:@""]) {
        [alert2 show];
    }else{
        [alert1 show];
    }
    
    
}

//键盘回收
-(BOOL)textFieldShouldReturn:(UITextField *)textField
{
    return [textField resignFirstResponder];
}




- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
